package recursion_demo;

import java.math.BigInteger;

/***
 * 递归阶乘  n! = n*(n-1)*(n-2)*...*1
 * 需要求取阶乘的数值
 *
 */
public class recursionMulitySum {

    public static BigInteger recursionMulitySum(BigInteger n){

        if (n.equals(BigInteger.ZERO)){

            return BigInteger.ZERO;
        }
        if (n.equals(BigInteger.ONE)){
            return BigInteger.ONE;
        }
        return n.multiply((recursionMulitySum(n.subtract(BigInteger.ONE))));
    }

    public static void main(String[] args) {

        BigInteger sum = recursionMulitySum(new BigInteger("10000"));
        System.out.println(sum);
    }
}
